<template lang="pug">
div
  nav-div
  div(v-html="article.content")
</template>

<script>
import { showArticle} from '../../vuex/action'
import NavDiv from '../../modules/nav'

export default {
  name: 'new',
  components: {
    NavDiv
  },
  vuex: {
    getters: {
       articleSource: ({ article }) => article.article,
    },
    actions: {
      showArticle
    }
  },
  data () {
    return { 
       id: null,
       article: {}
    }
  },
  ready () {
    this.load()
  },
   route: {
    data({ to: { params: { id }, query: { mode } } }) {
      this.id = id
    }
  },
  methods: {
    load(){
      catchError(async () => {
        await this.showArticle({id: this.id})
      })
    }
  },
  watch: {
     articleSource: {
      handler (val, old) {
        this.article = _.cloneDeep(val)
      },
      deep: true,
      immediate: true,
    },
  },
}
</script>

<style lang="sass" scoped>
</style>
